package com.ymatou.iapi.csim.testcase;

import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.csim.parameter.DiscourseDto;
import com.ymatou.iapi.csim.parameter.FetchByIdBean;
import com.ymatou.iapi.csim.parameter.SaveOrUpdateDiscourseBean;
import com.ymatou.iapi.csim.service.FetchByIdCall;
import com.ymatou.iapi.csim.service.SaveOrUpdateDiscourseCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CsimCallService;
import com.ymttest.database.model.ymt_discourse;
import com.ymttest.database.sqlwapper.CSIM.ymt_discourseWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
/**
*根据Id获取话术
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_FetchById{
	
	private static FetchByIdBean fetchbyidBean;
	private static FetchByIdCall fetchbyidCall;
	private Integer csId=Integer.parseInt(EnvSetup.getData("csId").toString());
	private static ymt_discourseWapper discourseWapperWapper=new ymt_discourseWapper();
	private  SaveOrUpdateDiscourseBean saveorupdatediscourseBean=new SaveOrUpdateDiscourseBean();;
	private  SaveOrUpdateDiscourseCall saveorupdatediscourseCall=new SaveOrUpdateDiscourseCall();
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("根据Id获取话术");
	}

	@Before
	public void caseUp() {
		fetchbyidBean=new FetchByIdBean();
		fetchbyidCall=new FetchByIdCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(fetchbyidCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_FetchById_1() {
		Logger.start(true,"根据Id获取话术");
		try {
			saveorupdatediscourseBean.setId(TestDataManager.getRandomUUID().toString());
			saveorupdatediscourseBean.setCategoryId(TestDataManager.getRandomUUID().toString());
			saveorupdatediscourseBean.setTitle("自动化测试_"+TestDataManager.getRandomNum(5));
			saveorupdatediscourseBean.setCsId(csId);
			saveorupdatediscourseBean.setSort(1);
			saveorupdatediscourseBean.setRoleType("MAIJIA_KEFU");
			saveorupdatediscourseCall.setData(saveorupdatediscourseBean);
			saveorupdatediscourseCall.callService();	
			
			
			fetchbyidBean.setCategoryId(saveorupdatediscourseBean.getCategoryId());
			fetchbyidBean.setId(saveorupdatediscourseBean.getId());
			fetchbyidCall.setData(fetchbyidBean);
			fetchbyidCall.callService();	
			//验证
			DiscourseDto disCall=fetchbyidCall.getData().getResult();
			ymt_discourse discourse=discourseWapperWapper.selectByPrimaryKey(fetchbyidBean.getId());
			
			Logger.verifyEquals("200", fetchbyidCall.getStatus(), "验证status");
			Logger.verifyEquals("", fetchbyidCall.getMsg(), "验证Msg");
			
			Logger.verifyEquals(disCall.getId(), discourse.getId(), "验证Id");
			Logger.verifyEquals(disCall.getCategoryId(), discourse.getCategoryId(), "验证CategoryId");
			Logger.verifyEquals(disCall.getTitle(), discourse.getTitle(), "验证Title");
			Logger.verifyEquals(disCall.getRoleType(), discourse.getRoleType(), "验证RoleType");
			Logger.verifyEquals(disCall.getCsId(), discourse.getCsId(), "验证CsId");
			Logger.verifyEquals(disCall.getSort(), discourse.getSort(), "验证Sort");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}